package services;

import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LogAspect {

    @Pointcut("execution(* services.*.*(..))")
    public void pointcutName(){}


    @Before("pointcutName()")
    public void performance(){
        System.out.println("Spring AOP");
    }

    @After("pointcutName()")
    public void afterExection(){
        System.out.println("Spring AOP afterExection");
    }


    @AfterThrowing(throwing="ex",pointcut="pointcutName())")
    public void doRecoveryActions(Throwable ex){
        System.out.println("目标方法中抛出的异常:"+ex);
        System.out.println("模拟抛出异常后的增强处理...");
    }
}